package com.wuyi.tea.config;

import com.wuyi.tea.interceptor.JwtInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Slf4j
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Autowired
    private JwtInterceptor jwtInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtInterceptor)
                .addPathPatterns("/**")
                //设置不拦截的请求路径，如登录接口不需要拦截等
                .excludePathPatterns("/login")
                .excludePathPatterns("/register")
            	//我使用了Knife4j测试文档，如果你没使用，可以不配置下面这行
                .excludePathPatterns("/doc.html","/swagger-resources");
    }
}